const CommentModel = require('../Model/CommentModel')
const commentModel = new CommentModel() 
class CommentController {
    async publish(req,res){
        try {
            let { username, movieId, commentObj } = req.body
            // console.log(req.body);
           await commentModel.publish({ username, movieId, commentObj })
           let obj = {
                code:200,
                data:'发布成功'
           }
           res.send(obj)
        } catch (error) {
            console.log(error);
        }
    }
    async list(req,res){
        try {
            let {username,movieId} = req.query
            let commentList = await commentModel.list({username,movieId})
            let obj = {
                code:200,
                data:commentList
            }
            res.send(obj)
        } catch (error) {
            console.log(error);
        }
    }
}
module.exports = CommentController